package com.zoe.app;

import com.zoe.app.annotation.LogArgs;
import lombok.SneakyThrows;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

/**
 * @author zbg
 * @date 2023/05/30
 * @description
 */
@Aspect
@Component
public class LogArgsAspect {
    @Around(value = "@annotation(logArgs)")
    @SneakyThrows
    public Object around(ProceedingJoinPoint proceedingJoinPoint,
                         LogArgs logArgs) {
        Object[] args = proceedingJoinPoint.getArgs();
        for (Object arg : args) {
            System.out.println(arg);
        }
        Object proceed = proceedingJoinPoint.proceed();
        return proceed;
    }
}
